package com.gexiaobao.pigeon.ui.dialog

import android.annotation.SuppressLint
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import androidx.appcompat.widget.AppCompatImageView
import androidx.appcompat.widget.AppCompatTextView
import com.gexiaobao.pigeon.R

/**
 * @author:hxw
 * @date  :2022/12/8
 * @desc  :
 */
class RxDialogRechargeRule(context: Context?) : RxDialog(context!!) {

    private lateinit var cancelView: AppCompatImageView
    private lateinit var titleView: AppCompatTextView
    private lateinit var contentView: AppCompatTextView

    init {
        initView()
    }

    @SuppressLint("MissingInflatedId")
    private fun initView() {
        val dialogView = LayoutInflater.from(context).inflate(R.layout.dialog_rechagre_rule, null)
        titleView = dialogView.findViewById(R.id.tvRuleDialogTitle)
        contentView = dialogView.findViewById(R.id.tvRuleDialogContent)
        cancelView = dialogView.findViewById(R.id.ivDialogRechargeRuleClose)
        cancelView.setOnClickListener {
            dismiss()
        }
        setContentView(dialogView)
    }

    fun setCancelListener(listener: View.OnClickListener?) {
        cancelView.setOnClickListener(listener)
    }

    fun setContent(content: String) {
        if (content.isEmpty()) {
            contentView.visibility = View.GONE
            return
        }
        contentView.text = content
        contentView.visibility = View.VISIBLE
    }

    fun setTitle(titleStr: String) {
        if (titleStr.isEmpty()) {
            titleView.visibility = View.GONE
            return
        }
        titleView.text = titleStr
        titleView.visibility = View.VISIBLE
    }
}